package cn.quevo.cube.provide.define.validate.tools;

import cn.quevo.cube.provide.exception.ColumnCheckException;
import cn.quevo.cube.provide.exception.response.ColumnExceptionResponse;

public class NumberTool {

    public static void checkNumber(Double min, Double max) {
        if (min == null && max == null) {
            return;
        }
        if ((min != null && min <= 0) || max != null && max <= 0) {
            throw new ColumnCheckException(ColumnExceptionResponse.MIN_VALUE_LT_ZERO);
        }
        if (min == null || max == null) {
            return;
        }
        if (min > max) {
            throw new ColumnCheckException(ColumnExceptionResponse.MAX_VALUE_LT_MIN_VALUE);
        }
    }

    public static void checkNumber(Integer min, Integer max) {
        checkNumber(min * 1.0, max * 1.0);
    }
}
